<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>员工信息列表</title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <script src="<%=path %>/resource/lib/plugins/ajaxfileupload.js"></script>
    <style>
        .project-span {
            border-radius: .25em;
            padding: .2em .6em .3em;
        }

        .project-span-success {
            color: #FFFFFF;
            background-color: #449d44;
            border-color: #449d44;
        }

        .project-span-dangeer {
            color: #FFFFFF;
            background-color: #d9534f;
            border-color: #d9534f;
        }

        .project-span-warning {
            color: #FFFFFF;
            background-color: #f0ad4e;
            border-color: #f0ad4e;
        }
    </style>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div class="searchArea">
        <form id="searchBar">
            <div class="fieldset1 clearFix">
                <div class="clearFix"></div>
                <div class="fieldBox" id="searchCstNmId">
                    <div class="label">选择excel:</div>
                    <div class="field">
                        <input name="excelFile" id="excelFile" type="file">
                    </div>
                </div>
                <div class="btnsBox formBtns notRight">
                    <span onclick="importExcel();" class="sq-button-round">导入</span>
                </div>
            </div>
        </form>
    </div>
</div>
<div id="employeeGrid" class="sq-grid"></div>
</div>

<script type="text/javascript">
    var grid = null;
    $(function () {
        initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
    });


    //查询参数
    function getSearchParams(){
/*        var form = new liger.get("searchBar");
        var data = form.getData();*/
        return {};
    }

    //初始化列表
    function initGrid(){
        $("#employeeGrid").ligerGrid({
            url: '<%=path%>/relationmap/employee/rmemployeebscinfo/initList.do',
            method : 'post',
            isSingleCheck: true,

            parms:getSearchParams(),
            columns: [
                { display: '员工姓名', name: 'batchNo', width: 150},
                { display: '工号', name: 'lsCntNo', minWidth: 140 }
            ],
            pageSize:10,
            root:'rows',
            record:'total',
            hideLoadButton : true,
            width: '100%',
            height:'100%',
            heightDiff:-2,
            //checkbox:true,
            rownumbers:true
        });
        grid = liger.get("employeeGrid");
        grid.setHeight(100);
    }


    //导入
    function importExcel() {

        if ($("#excelFile").val().length == 0) {
            alert("请选择要上传的文件!");
        } else {
            var upload_dialog = UIUtils.alertWaiting("上传中...", function () {
            });
            $.ajaxFileUpload
            (
                {
                    url: '<%=path%>/relationmap/employee/rmemployeebscinfo/addBatchByUpload.do', //用于文件上传的服务器端请求地址
                    secureuri: false, //是否需要安全协议，一般设置为false
                    fileElementId: 'excelFile', //文件上传域的ID
                    dataType: 'json', //返回值类型 一般设置为json
                    success: function (data, status)  //服务器成功响应处理函数
                    {
                        upload_dialog.close();
                        if (data.success == 1) {
                            alert("上传成功，稍后刷新页面查询最新数据!");
                        } else {
                            alert(data.info);
                        }


                    },
                    error: function (data, status, e)//服务器响应失败处理函数
                    {
                        upload_dialog.close();
                        console.log(data)
                    }
                })
        }
    }

    function iframeResize () {
        if (parent.mainApp) {
            parent.mainApp.parentTab.onResize();
        };
    }
</script>


</body>
</html>